package com.smarthospital.web.controller;

import com.smarthospital.common.Result.ResultDTO;
import com.smarthospital.entity.pojo.Report;
import com.smarthospital.service.ReportService;
import com.smarthospital.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * create by sym  2020/8/16 16:00.
 */
@RestController
@Slf4j
@RequestMapping("/report")
@Api(description = "报告接口",value = "report")
public class ReportController {

    @Autowired
    private ReportService reportService;
    @Autowired
    private UserService userService;

    @Autowired
    private StringRedisTemplate redisTemplate;

    @GetMapping("/list")
    @ApiOperation(value = "我的报告",
            notes =" 我的报告，根据医院分开\n "  )
    public ResultDTO list(@RequestHeader("SH_TOKEN")String SH_TOKEN){
        Map<String, List<Report>> map = reportService.querMyReports();
        return ResultDTO.sucess(map);
    }

    @GetMapping("/getReportByHos")
    @ApiOperation(value = "提取医院报告",
            notes =" 提取医院报告，根据医院id拉取\n "  )
    public ResultDTO getReportByHos(@RequestParam("hospitalId")Long hospitalId,@RequestHeader("SH_TOKEN")String SH_TOKEN){
        List<Report> list = reportService.getReportByHos(hospitalId);
        return ResultDTO.sucess(list);
    }



}
